﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace CJAtech.BBS.Process
{
    public partial class BBSBaseController
    {
        /// <summary>
        /// 获取评论列表
        /// </summary>
        /// <param name="articleId">文章Id</param>
        /// <param name="commentID"></param>
        /// <param name="position"></param>
        /// <param name="loadCount"></param>
        /// <param name="isLoadFloor"></param>
        /// <param name="isLoadRelatedRecord"></param>
        /// <returns></returns>
        [OutputCache(Duration = 2)]
        public virtual JsonResult GetCommentList(int? articleId, int? commentID, string position, int? loadCount, int? isLoadFloor = 0, int? isLoadRelatedRecord = 1)
        {
            return Json(CurrentBBSProcess.GetCommentList(articleId, commentID, position, loadCount,isLoadFloor, isLoadRelatedRecord), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 获取热门评论
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="isLoadFloor"></param>
        /// <param name="isLoadRelatedRecord"></param>
        /// <returns></returns>
        [OutputCache(Duration = 2)]
        public virtual JsonResult GetCommentHotList(int? articleId, int? pageIndex = 1, int? pageSize = 10, int? isLoadFloor = 0, int? isLoadRelatedRecord = 1)
        {
            return Json(CurrentBBSProcess.GetCommentHotList(articleId, pageIndex, pageSize, isLoadFloor, isLoadRelatedRecord), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 获取评论列表
        /// </summary>
        /// <param name="articleId">文章Id</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="isLoadFloor"></param>
        /// <param name="isLoadRelatedRecord"></param>
        /// <returns></returns>
        [OutputCache(Duration = 2)]
        public virtual JsonResult GetCommentPageList(int? articleId, int? pageIndex = 1, int? pageSize = 10, int? isLoadFloor = 0, int? isLoadRelatedRecord = 1)
        {
            return Json(CurrentBBSProcess.GetCommentPageList(articleId, pageIndex, pageSize, isLoadFloor, isLoadRelatedRecord), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 展开评论楼层列表
        /// </summary>
        /// <param name="commentId"></param>
        /// <param name="previousFloorId"></param>
        /// <param name="floorCount"></param>
        /// <returns></returns>
        [OutputCache(Duration = 2)]
        public virtual JsonResult GetCommentRestFloorList(int? commentId, int? previousFloorId, int? floorCount = 20)
        {
            return Json(CurrentBBSProcess.GetCommentRestFloorList(commentId, previousFloorId, floorCount), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 轮询是否有最新评论
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="commentID"></param>
        /// <returns></returns>
        public virtual JsonResult HasCommentLatest(int? articleId, int? commentID)
        {
            return Json(CurrentBBSProcess.HasCommentLatest(articleId, commentID), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="replyId"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        [HttpPost]
        [ValidateInput(false)]
        public virtual JsonResult AddComment(int? articleId, int? replyId, string content)
        {
            return Json(CurrentBBSProcess.AddComment(articleId, replyId, content));
        }
        /// <summary>
        /// 评论点赞
        /// </summary>
        /// <param name="commentId"></param>
        /// <param name="articleId"></param>
        /// <returns></returns>
        public virtual JsonResult DiggComment(int? commentId, int? articleId)
        {
            return Json(CurrentBBSProcess.DiggComment(commentId, articleId), JsonRequestBehavior.AllowGet);
        }
    }
}
